﻿using System.Data;
using System.Data.SqlClient;
using Pantry.Commons;

namespace Pantry.DataAccess
{
    public class ServiceOrgDao
    {
        private readonly SqlConnection _sqlConnection;
        public ServiceOrgDao()
        {
            _sqlConnection = SqlConnectionTool.SqlGetConnection();
        }
        #region Constant

        private const string SqlSelect = @"SELECT [ServiceID]
          ,[ServiceParentID]
          ,[ServiceName] FROM [Service_Org] WHERE [ServiceParentID] = @ServiceParentID ";
        #endregion

        /// <summary>
        /// Selects the specified service parent id.
        /// </summary>
        /// <param name="serviceParentId">The service parent id.</param>
        /// <returns></returns>
        public DataTable Select (int serviceParentId)
        {
            var parentId = new SqlParameter("@ServiceParentID", SqlDbType.Int) {Value = serviceParentId};
            return SqlHelper.ExecuteDataSet(_sqlConnection, CommandType.Text, SqlSelect, parentId).Tables[0];
        }

    }
}
